<%--                                                                       --%>
<%-- Copyright (c) 2001-2006 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries.                       --%>
<%--                                                                       --%>

<%@ page import="org.apache.struts.action.*" %>
<%@ page import="com.broadvision.portal.services.microsite.MicrositeProperty" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.text.DateFormat" %>
<%@ page import="org.apache.commons.beanutils.PropertyUtils" %>

<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/bv-html.tld" prefix="bvhtml" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>

  <!-- start javascript functions here.  -->
  <script language="javascript">
  <!--
    function onClickCloseCollaboration() {

      var pendingTasks = <bean:write name="collaborationSummaryView" property="pendingTasksCount"/>;
      var pendingChecklists = <bean:write name="collaborationSummaryView" property="pendingChecklistsCount"/>;
      var pendingMeetings = <bean:write name="collaborationSummaryView" property="pendingMeetingsCount"/>;

      var okay = true;

      if (pendingTasks > 0 || pendingChecklists > 0 || pendingMeetings > 0) {
        var errorMsg = '<bean:message key="cs.collaboration.summary.alert.msg"/>';
        <c:if test="${micrositeNaviInfoView.map.isMicrosite}">
          var question = '<bean:message key="cs.microsite.summary.alert.continue"/>';
        </c:if>
        <c:if test="${!micrositeNaviInfoView.map.isMicrosite}">
          var question = '<bean:message key="cs.collaboration.summary.alert.continue"/>';
        </c:if>
        
        okay  = confirm(errorMsg + "\n" + question);
      }

      if (okay) {
        document.micrositeSummaryEditForm.submit();
      } else {
        return false;
      }
    }
  
    function onClickButton(theForm, url) {
      theForm.action = url;
      theForm.submit();
    }

    function onClickReset() {
      document.micrositeSummaryEditForm.reset();
    }
    // -->

    function doLoad() {
      if (self.opener !=null && self.opener != "" && self.opener.name != undefined) {
        self.opener.refreshOpener();
      }
    }

  </script>
  <!-- End javascript functions here.  -->


<!-- body tile -->
<body onload="doLoad()" >

  <!-- Zone 5 starts here.  -->
    
  <table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="10" 
    summary='<bean:message key="cs.collaboration.summary.table.summary1"/>' >
  <!--start page title area here-->
  <tr>
    <td colspan="2" valign="top">
      <div class="pageTitle">
       <img src="<%= request.getContextPath()%>/cs/images/icons/collaboration.gif"
         align="absmiddle" alt="Collaboration logo">
         <bean:write name="micrositeNaviInfoView" property="micrositeName"/>&nbsp;<bean:message key="cs.collaboration.summary.pageTitle" />
      </div>
      <div class="errorMessage">
       <html:errors/>
      </div>
    </td>
  </tr>
  <!--end page title area here-->

  <%
     com.broadvision.web.util.ViewDynaBean roleUserListView = (com.broadvision.web.util.ViewDynaBean) request.getAttribute("collaborationSummaryView");
     boolean usePhase = true;
     
     try {
       Boolean b = (Boolean)PropertyUtils.getProperty(roleUserListView, "usePhase");
       if (null != b)
         usePhase = b.booleanValue();
     }
     catch (Exception ee) {
     }
  %>

  <!--start page blocks area here-->
  <tr>
    <td valign="top" width="50%" align="center">
  <!-- Start Phase block -->
    <div class="blockTitle">
        <span class="left"><bean:message key="cs.phases"/></span>
      <span class="right">&nbsp;</span>
    </div> 
    <table width="100%" class="blockTable" border="0" cellspacing="1" cellpadding="2" 
      summary='<bean:message key="cs.collaboration.summary.phaseTable"/>' >
      <tr class="listHeader"> 
        <th id="PhaseName" align="left">
            <bean:message key="cs.name"/>
        </th>
        <th id="Status" align="left"><bean:message key="cs.status"/></th>
      </tr>
<% if (usePhase) { %>
      <logic:iterate id="phase" property="phases" name="collaborationSummaryView" indexId="index">
        <tr class='<%=index.intValue() %2 == 0 ? "listOdd" : "listEven"%>'>
          <td headers="PhaseName" align="left">
            <bean:write name="phase" property="name"/>&nbsp;
          </td>
          <td headers="Status" align="left">
            <bean:write name="phase" property="status"/>&nbsp;
          </td>
         </tr>
      </logic:iterate>
      <logic:equal name="collaborationSummaryView" property="phases.empty" value="true">
         <tr class="listOdd">
           <td align="center" colspan="5">
             <bean:message key="cs.collaboration.noPhases"/>
           </td>
         </tr>
      </logic:equal>
<% } else { %>
         <tr class="listOdd">
           <td align="center" colspan="5">
             <bean:message key="cs.collaboration.noPhases"/>
           </td>
         </tr>
<% } %>
    </table>
  <!-- End Phase block -->

  <!-- Meetings block --> 
    <div class="blockTitle">
      <span class="left"><bean:message key="cs.pendingMeetings"/></span>
      <span class="right">&nbsp;</span>
    </div>
    
    <table width="100%" class="blockTable" border="0" cellspacing="1" cellpadding="2" 
      summary='<bean:message key="cs.collaboration.summary.meetingTable"/>'>
      <tr class="listHeader">
        <th id="Name" align="left">
          <bean:message key="cs.name"/>
        </th>
        <th id="Owner" align="left">
          <bean:message key="cs.owner"/>
        </th>
        <th id="DateAndTime" align="left">
          <bean:message key="cs.date.and.time"/>
        </th>
<% if (usePhase) { %>
        <th id="Phase" align="left">
          <bean:message key="cs.phase"/>
        </th>
<% } %>
      </tr>
      <logic:iterate id="meeting" property="pendingMeetings" name="collaborationSummaryView" indexId="index">
        <tr class='<%=index.intValue() %2 == 0 ? "listOdd" : "listEven"%>'>
          <td headers="Name" align="left">
             <html:link page="/cs/meetingView.do" name="meeting" property="urlParams">
               <bean:write name="meeting" property="name"/>&nbsp;
             </html:link>
          </td>
          <td headers="Owner" align="left">
            <bean:write name="meeting" property="ownerName"/>&nbsp;
          </td>
          <td headers="DateAndTime" align="left">
            <bean:write name="meeting" property="startDate" formatKey="format.date.full"/><br>
            <bean:write name="meeting" property="startDate" formatKey="format.time.short"/> -  
            <bean:write name="meeting" property="endDate" formatKey="format.time.short"/>&nbsp;
          </td>
<% if (usePhase) { %>
          <td headers="Phase" align="left">
            <bean:write name="meeting" property="phaseName"/>&nbsp;
          </td>
<% } %>
        </tr>
      </logic:iterate>
      <logic:equal name="collaborationSummaryView" property="pendingMeetings.empty" value="true">
        <tr class="listOdd">
          <td align="center" colspan="5">
            <bean:message key="cs.collaboration.noMeetings"/>
          </td>
        </tr>
      </logic:equal>
    </table>
  <!-- End Meetings block -->
    </td>

  <!-- End first column -->
  <!-- Start Second column -->

    <td valign="top" width="50%" align="center">
    <!-- Tasks block --> 
      <div class="blockTitle">
      <span class="left"><bean:message key="cs.pendingTasks"/></span>
      <span class="right">&nbsp;</span>
    </div>
    <logic:greaterThan name="collaborationSummaryView" property="tasksCount" 
                  value="0">
    <div class="blockStatusText">
      <bean:write name="collaborationSummaryView" property="completedTasksCount"/>&nbsp;
      <bean:message key="cs.out.of"/>
      <bean:write name="collaborationSummaryView" property="tasksCount"/>
      <bean:message key="cs.tasks.completed"/>
    </div> 
    </logic:greaterThan>
    
    <table width="100%" class="blockTable" border="0" cellspacing="1" cellpadding="2" 
      summary='<bean:message key="cs.collaboration.summary.taskTable"/>'>
      <tr class="listHeader"> 
        <th id="Name" align="left">
          <bean:message key="cs.name"/>
        </th>
        <th id="Owner" align="left">
          <bean:message key="cs.owner"/>
        </th>
        <th id="DueDate" align="left">
          <bean:message key="cs.dueDate"/>
        </th>
<% if (usePhase) { %>
        <th id="Phase" align="left">
          <bean:message key="cs.phase"/>
        </th>
<% } %>
      </tr>
      <logic:iterate id="task" property="pendingTasks" name="collaborationSummaryView" indexId="index">
        <tr class='<%=index.intValue() %2 == 0 ? "listOdd" : "listEven"%>'>
          <td headers="Name" align="left">
            <html:link page="/cs/taskView.do" name="task" property="urlParams">
              <bean:write name="task" property="name"/>&nbsp;
            </html:link>
          </td>
          <td headers="Owner" align="left">
            <bean:write name="task" property="ownerName"/>&nbsp;
          </td>
          <td headers="DueDate" align="left">
            <bean:write name="task" property="dueDate" formatKey="format.date.medium"/>&nbsp;
          </td>
<% if (usePhase) { %>
          <td headers="Phase" align="left">
            <bean:write name="task" property="phaseName"/>&nbsp;
          </td>
<% } %>
        </tr>
      </logic:iterate>
      <logic:equal name="collaborationSummaryView" property="pendingTasks.empty" value="true">
        <tr class="listOdd">
          <td align="center" colspan="5">
            <bean:message key="cs.collaboration.noTasks"/>
          </td>
        </tr>
      </logic:equal>
    </table>
  <!-- End Tasks block --> 

  <!-- Start Checklists block --> 
    <div class="blockTitle">
      <span class="left">
        <bean:message key="cs.pendingChecklists"/>
      </span>
      <span class="right">&nbsp;</span>
    </div>
  <logic:greaterThan name="collaborationSummaryView" property="checklistsCount" 
                  value="0">
    <div class="blockStatusText">
      <bean:write name="collaborationSummaryView" property="completedChecklistsCount"/>&nbsp;
      <bean:message key="cs.out.of"/>
      <bean:write name="collaborationSummaryView" property="checklistsCount"/>
      <bean:message key="cs.tasks.completed"/>
    </div> 
  </logic:greaterThan>

    <table width="100%" class="blockTable" border="0" cellspacing="1" cellpadding="2" 
      summary='<bean:message key="cs.collaboration.summary.checklistTable"/>' >
      <tr class="listHeader"> 
        <th id="Name" align="left">
          <bean:message key="cs.name"/>
        </th>
        <th id="Owner" align="left">
          <bean:message key="cs.owner"/>
        </th>
        <th id="DueDate" align="left">
          <bean:message key="cs.dueDate"/>
        </th>
<% if (usePhase) { %>
        <th id="Phase" align="left">
          <bean:message key="cs.phase"/>
        </th>
<% } %>
      </tr>
      <logic:iterate id="checklist" property="pendingChecklists" name="collaborationSummaryView" indexId="index">
        <tr class='<%=index.intValue() %2 == 0 ? "listOdd" : "listEven"%>'>
          <td headers="Name" align="left">
            <html:link page="/cs/checklistTaskList.do" name="checklist" property="urlParams">
              <bean:write name="checklist" property="name"/>&nbsp;
            </html:link>
          </td>
          <td headers="Owner" align="left">
            <bean:write name="checklist" property="ownerName"/>&nbsp;
          </td>
          <td headers="DueDate" align="left">
            <bean:write name="checklist" property="dueDate" formatKey="format.date.medium"/>&nbsp;
          </td>
<% if (usePhase) { %>
          <td headers="Phase" align="left">
            <bean:write name="checklist" property="phaseName"/>&nbsp;
          </td>
<% } %>
        </tr>
      </logic:iterate>
      <logic:equal name="collaborationSummaryView" property="pendingChecklists.empty" value="true">
        <tr class="listOdd">
          <td align="center" colspan="5">
            <bean:message key="cs.collaboration.noChecklists"/>
          </td>
        </tr>
      </logic:equal>
    </table>
  <!-- End Checklists block -->

    </td>
  </tr>
  <!-- end of two column row -->
  <tr>
    <td colspan="2" valign="top">
      <div class="blockTitle">
        <span class="left">
          <bean:message key="cs.collaboration.summary.closingTitle"/>
        </span>
        <span class="right">&nbsp;</span>
      </div>
  
      <div class="blockWrap">  
        <logic:equal name="collaborationSummaryView" property="displayButtons" 
                  value="true">
          <logic:notEqual name="collaborationSummaryView" property="displayCloseButton" 
                  value="true">
                  
          <div class="pageInstructions">
            <c:if test="${micrositeNaviInfoView.map.isMicrosite}">
              <bean:message key="cs.microsite.summary.pageInstructions"/>
            </c:if>  
            <c:if test="${!micrositeNaviInfoView.map.isMicrosite}">
              <bean:message key="cs.collaboration.summary.pageInstructions"/>
            </c:if>  
          </div>
          </logic:notEqual>
        </logic:equal>

  <!--start close collaboration form here-->
    <html:form action="/cs/closeCollaboration.do">
      <bvhtml:hiddenList name="micrositeNaviInfoView" property="urlParams" scope="request"/>
      <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="0" 
        summary='<bean:message key="cs.collaboration.summary.closingTitle"/>'>

    <logic:greaterThan name="collaborationSummaryView" property="outputPropertiesCount" value="0">

      <logic:iterate id="outputProperty" property="outputProperties" name="collaborationSummaryView" indexId="index">
        <logic:notEqual name="outputProperty" property="dataType" value="<%=String.valueOf(MicrositeProperty.XML_TYPE)%>">
          <!-- not DateTime -->
          <logic:notEqual name="outputProperty" property="dataType" value="<%=String.valueOf(MicrositeProperty.DATETIME_TYPE)%>">
            <!-- not Boolean -->
            <logic:notEqual name="outputProperty" property="dataType" value="<%=String.valueOf(MicrositeProperty.BOOLEAN_TYPE)%>">
      <tr> 
        <td class="label" width="15%"><bean:write name="outputProperty" property = "name"/>:</td>
        <td class="labelField" width="85%">
          <input type="hidden" name="name" value='<bean:write name="outputProperty" property="name"/>'>
          <input type="text" size="60" maxlength="80" name="values" 
            value='<bean:write name="outputProperty" property="value"/>'>       
        </td>
      </tr>
            </logic:notEqual>  <!-- not Boolean -->
            <!-- is Boolean -->
            <logic:equal name="outputProperty" property="dataType" value="<%=String.valueOf(MicrositeProperty.BOOLEAN_TYPE)%>">
      <tr>
        <% {  
          Object oo = pageContext.getAttribute("outputProperty");
          boolean isTrue = (null != oo ? Boolean.getBoolean(oo.toString()) : false);
        %> 
        <td class="label" width="15%"><bean:write name="outputProperty" property="name"/>:</td>
        <td class="labelField" width="85%">
          <input type="hidden" name="name" value='<bean:write name="outputProperty" property="name"/>'>
          <input type="radio" name="values" value="<%= Boolean.TRUE.toString() %>" <%= isTrue ? "checked" : "" %>><bean:message key="cs.collaboration.summary.boolean.true"/>
          <input type="radio" name="values" value="<%= Boolean.FALSE.toString() %>" <%= !isTrue ? "checked" : "" %>><bean:message key="cs.collaboration.summary.boolean.false"/>
        </td>
        <% } %>     
      </tr>
            </logic:equal>  <!-- is Boolean -->            
          </logic:notEqual>  <!-- not DateTime -->
          <!-- is DateTime -->
          <logic:equal name="outputProperty" property="dataType" value="<%=String.valueOf(MicrositeProperty.DATETIME_TYPE)%>">
      <tr> 
        <td class="label" width="15%"><bean:write name="outputProperty" property="name"/>:</td>
        <td class="labelField" width="85%">
          <input type="hidden" name="name" value='<bean:write name="outputProperty" property="name"/>'>
          <input type="text" size="60" maxlength="80" name="values" 
            value='<bean:write name="outputProperty" property="value" format="<%=((SimpleDateFormat) DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, request.getLocale())).toPattern()%>"/>'>&nbsp;
        </td>
      </tr>
          </logic:equal>   <!-- is DateTime -->
        </logic:notEqual>  <!-- not XML -->
<!--
        <logic:equal name="outputProperty" property="dataType" value="<%=String.valueOf(MicrositeProperty.XML_TYPE)%>">
      <tr> 
        <td class="label" width="15%"><bean:write name="outputProperty" property="name"/>:</td>
        <td class="labelField" width="85%">
          <input type="hidden" name="name" value='<bean:write name="outputProperty" property="name"/>'>
          <textarea cols="40" rows="5" name="value" wrap="virtual"><bean:write name="outputProperty" property="value"/></textarea> 
        </td>
      </tr>
      </logic:equal>
-->
      </logic:iterate>
    </logic:greaterThan>

    <logic:lessEqual name="collaborationSummaryView" property="outputPropertiesCount" value="0">
          <tr>
            <td class="labelField" align="center">
            <c:if test="${micrositeNaviInfoView.map.isMicrosite}">
              <bean:message key="cs.microsite.summary.outputMessage"/>
            </c:if>
            <c:if test="${!micrositeNaviInfoView.map.isMicrosite}">
              <bean:message key="cs.collaboration.summary.outputMessage"/>
            </c:if>
            </td>
          </tr>
    </logic:lessEqual>
    </table>  
    
  <!-- Start reset, cancel, save, close collaboration buttons here -->
    <logic:equal name="collaborationSummaryView" property="displayButtons" value="true">
      <div class="pageButtonWrap" align="right">

          <logic:greaterThan name="collaborationSummaryView" property="outputPropertiesCount" 
            value="0">
            <input hspace="40" type="button" class="pageButton" name="resetBtn"
                 value='<bean:message key="button.reset"/>'
                 titleKey="button.reset"
                 onclick="onClickReset()">
          </logic:greaterThan>

          <input hspace="40" type="button" class="pageButton" name="cancelBtn"
                      value='<bean:message key="button.cancel"/>'
                      titleKey="button.cancel"
                      onclick="return history.back()">&nbsp;&nbsp; 

          <logic:greaterThan name="collaborationSummaryView" property="outputPropertiesCount" 
            value="0">
            <input hspace="40" type="button" class="pageButton" name="saveBtn"
               value='<bean:message key="button.save"/>'
               titleKey="button.save"
               onclick="onClickButton(this.form, '<html:rewrite page="/cs/collaborationSummarySave.do"/>')">
          </logic:greaterThan>

         <c:if test="${micrositeNaviInfoView.map.isMicrosite}">  
          <logic:equal name="collaborationSummaryView" property="displayCloseButton" 
                  value="true">   
            <input hspace="40" type="button"  class="pageButton" name="closeBtn"
               titleKey="cs.microsite.close.button" onclick="onClickCloseCollaboration()"
               value='<bean:message key="cs.microsite.close.button"/>'>
          </logic:equal>
          <logic:notEqual name="collaborationSummaryView" property="displayCloseButton" 
                  value="true">
            <input hspace="40" type="button"  class="disabledButton" name="closeBtnDisabled"
               titleKey="cs.microsite.close.button" disable="true"
               value='<bean:message key="cs.microsite.close.button"/>'>
          </logic:notEqual>
         </c:if>
         
        <c:if test="${!micrositeNaviInfoView.map.isMicrosite}">  
         <logic:equal name="collaborationSummaryView" property="displayCloseButton" 
                 value="true">   
           <input hspace="40" type="button"  class="pageButton" name="closeBtn"
               titleKey="cs.collaboration.close.button" onclick="onClickCloseCollaboration()"
               value='<bean:message key="cs.collaboration.close.button"/>'>
         </logic:equal>
         <logic:notEqual name="collaborationSummaryView" property="displayCloseButton" 
                 value="true">
           <input hspace="40" type="button"  class="disabledButton" name="closeBtnDisabled"
               titleKey="cs.collaboration.close.button" disable="true"
               value='<bean:message key="cs.collaboration.close.button"/>'>
         </logic:notEqual>
        </c:if>         
      </div>
    </logic:equal>
  <!-- End reset, cancel, save, start collaboration buttons here -->

    </html:form>
  <!-- end form here -->
     </div> <!-- end blockWrap here -->
    </td>
  </tr>
  </table>
  <!--end zone 5 content here -->

